package cn.openea.perpartner.meily.constant.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * @author ysk
 * @version 1.0.1
 * @Description 测评等级
 * @createTime 2023年03月28日 13:46:00
 */
public enum AssessmentLevelEnums {

    A(1, "A"),
    B(2, "B"),
    C(3, "C"),
    D(4, "D"),
    E(5, "E"),
    F(7, "F"),

    ;

    /**
     * 排序
     */
    private final Integer sort;

    /**
     * 等级
     */
    private final String Level;

    AssessmentLevelEnums(Integer sort, String Level) {
        this.sort = sort;
        this.Level = Level;
    }

    public Integer getSort() {
        return sort;
    }

    public String getLevel() {
        return Level;
    }

    public static AssessmentLevelEnums getInstance(String Level) {
        if (StringUtils.isBlank(Level)) {
            return null;
        }
        for (AssessmentLevelEnums value : values()) {
            if (value.Level.equals(Level)) {
                return value;
            }
        }
        return null;
    }

    /**
     * 比较是否满足等级
     *
     * @param requirementLevel 要求的级别
     * @param currentLevel     当前等级
     * @return boolean
     */
    public static boolean compareGrades(String requirementLevel, String currentLevel) {
        if (StringUtils.isBlank(requirementLevel) || StringUtils.isBlank(currentLevel)) {
            return false;
        }
        AssessmentLevelEnums requirement = getInstance(requirementLevel);
        AssessmentLevelEnums current = getInstance(currentLevel);
        if (requirement == null || current == null) {
            return false;
        }
        return requirement.sort >= current.sort;
    }
}
